<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
<html>
<head>
	<title>学生管理管理</title>
	<meta name="decorator" content="default"/>
	<script type="text/javascript">
		$(document).ready(function() {
			$("#btnImport").click(function () {
				$.jBox($("#importBox").html(), {
					title: "导入学生数据", buttons: {"关闭": true},
					bottomText: "导入文件不能超过5M，仅允许导入“xls”或“xlsx”格式文件！"
				});
			});
		});
		function page(n,s){
			$("#pageNo").val(n);
			$("#pageSize").val(s);
			$("#searchForm").submit();
        	return false;
        }

		//查看所属班级
		function viewBelongClass(id){
			console.info(id);
			$.ajax({
				type: "POST",
				url: "${ctx}/teach/teachStudent/viewBelongClass",
				data: {
					userId:id
				},
				success: function (Class) {
					for (var i = 0; i < Class.length; i++) {
						$("#viewBelongClass").append("<li>" + Class[i].className + "</li>");
					}
				},
				error:function(){
					console.info("error");
				}
			});
			$.jBox($("#viewBelongClassBox").html(), {title:"查看所属班级", buttons:{"关闭":true}, submit: function(){}});
		}
	</script>
	<script type="text/template" id="viewBelongClassBox">
		<div>
			<ul id="viewBelongClass">
			</ul>
		</div>
	</script>
</head>
<body>
<div id="importBox" class="hide">
	<form id="importForm" action="${ctx}/teach/teachStudent/import" method="post" enctype="multipart/form-data"
		  class="form-search" style="padding-left:20px;text-align:center;" onsubmit="loading('正在导入，请稍等...');"><br/>
		<input id="uploadFile" name="file" type="file" style="width:330px"/><br/><br/>　　
		<input id="btnImportSubmit" class="btn btn-primary" type="submit" value="   导    入   "/>
		<a href="${ctx}/teach/teachStudent/import/template">点此下载导入模板</a>
	</form>
</div>
	<ul class="nav nav-tabs">
		<li class="active"><a href="${ctx}/teach/teachStudent/">学生管理列表</a></li>
		<shiro:hasPermission name="teach:teachStudent:edit"><li><a href="${ctx}/teach/teachStudent/form">学生管理添加</a></li></shiro:hasPermission>
	</ul>
	<form:form id="searchForm" modelAttribute="teachStudent" action="${ctx}/teach/teachStudent/" method="post" class="breadcrumb form-search">
		<input id="pageNo" name="pageNo" type="hidden" value="${page.pageNo}"/>
		<input id="pageSize" name="pageSize" type="hidden" value="${page.pageSize}"/>
		<ul class="ul-form">
			<li><label>学生姓名：</label>
				<form:input path="name" htmlEscape="false" maxlength="100" class="input-medium"/>
			</li>
			<li><label>所属班级：</label>
				<select id="classId" name="classId" class="input-medium">
					<option value="" selected>====请选择====</option>
					<%--<option value="0">无</option>--%>
					<c:forEach items="${allClassList}" var="allClass">
						<option value="${allClass.id}" >${allClass.className}</option>
					</c:forEach>
				</select>
			</li>
			<li class="btns">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input id="btnSubmit" class="btn btn-primary" type="submit" value="查询"/></li>
			<li>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input id="btnImport" class="btn btn-primary" type="button" value="导入Excel添加"/></li></li>
			<li>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a class="btn btn-primary" href="${ctx}/teach/teachStudent/batchAddForm">批量添加到班级</a></li>
			<li class="clearfix"></li>
		</ul>
	</form:form>
	<sys:message content="${message}"/>
	<table id="contentTable" class="table table-striped table-bordered table-condensed">
		<thead>
			<tr>
				<th>学生姓名</th>
				<th>用户名</th>
				<th>所属班级</th>
				<shiro:hasPermission name="teach:teachStudent:edit"><th>操作</th></shiro:hasPermission>
			</tr>
		</thead>
		<tbody>
		<c:forEach items="${page.list}" var="teachStudent">
			<tr>
				<td><a href="${ctx}/teach/teachStudent/form?id=${teachStudent.id}">${teachStudent.name}</a></td>
				<td>${teachStudent.loginName}</td>
				<td><a href="javascript:viewBelongClass('${teachStudent.id}')" title="查看所属班级">查看所属班级</a></td>
				<shiro:hasPermission name="teach:teachStudent:edit"><td>
    				<a href="${ctx}/teach/teachStudent/form?id=${teachStudent.id}">修改</a>
					<a href="${ctx}/teach/teachStudent/delete?id=${teachStudent.id}" onclick="return confirmx('确认要删除该学生吗？', this.href)">删除</a>
				</td></shiro:hasPermission>
			</tr>
		</c:forEach>
		</tbody>
	</table>
	<div class="pagination">${page}</div>
</body>
</html>